# Author    : CoffeeChicken
# Date      : 2020-12-02 21:57
# Function  : 演示 修改url中的参数

from furl import furl
import requests
headers = {
    'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko)'
                  ' Chrome/66.0.3329.0 Mobile Safari/537.36'
}
url = "https://aweme.snssdk.com/aweme/v1/play/?video_id=v0300f820000bu1f8m3oe0n4735hop5g" \
      "&line=0&ratio=540p&media_type=4&vr_type=0&improve_bitrate=0&is_play_url=1&source=PackSourceEnum_DOUYIN_REFLOW"

result = furl(url)

print(result.args["ratio"])

result.args["ratio"] = "720p"

print(result.url)

# est = requests.get(url=url, headers=headers)
# with open(f'1.mp4', 'wb') as f:
#     f.write(est.content)

est = requests.get(url=result.url, headers=headers)
with open(f'3.mp4', 'wb') as f:
    f.write(est.content)
